Attributes of an HTML Tag
Attributes provide additional information about an HTML element. They are always included in the opening tag and usually come in name/value pairs, such as name="value". Attributes help modify the behavior, appearance, or meaning of an element.
id – uniquely identifies an element
class – assigns a class for styling or scripting
src – specifies the source file (e.g., images, scripts)
href – specifies the link URL
alt – provides alternative text for images
title – gives additional information shown as a tooltip
style – allows inline CSS styling
width/height – defines element dimensions
disabled – makes form elements uneditable or unclickable
You need to add a tooltip to a button using only HTML. Which attribute would you use and why?
If you write <div class="card" without closing the tag, what happens to the class attribute when the browser parses the page?
Your teammate added a data-user-id attribute to a div, but it doesn't appear in the DOM inspector. Walk me through how you'd debug the issue.
We need to make an image accessible for screen readers. Which attributes would you add to the <img> tag and what trade‑offs should we consider?
During a refactor, the type="email" attribute was removed from an <input> and the form started accepting invalid data. Explain why that attribute matters.
We're building a component library used across many products. How would you decide which HTML attributes to expose as component props, and how would you handle deprecating old ones?
Our analytics team wants to add data- attributes to every interactive element without bloating the markup. What strategies would you use to manage attribute size and performance at scale?
When implementing server‑side rendering for a large SPA, how do you ensure that boolean attributes are rendered correctly to avoid hydration mismatches?
Our organization is migrating legacy pages that heavily use inline event attributes like onclick. How would you plan the migration to preserve functionality while moving to a modern framework?
We need to define a company‑wide HTML attribute naming convention that works across multiple front‑end stacks and supports accessibility. What factors would you consider and how would you enforce it?